home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pico / pico.h < prev    next >
C/C++ Source or Header  |  1996-07-09  |  15KB  |  472 lines

  1. /*
  2.  * $Id: pico.h,v 4.75 1996/07/09 22:49:32 mikes Exp $
  3.  *
  4.  * Program:    pico.h - definitions for Pine's composer library
  5.  *
  6.  *
  7.  * Michael Seibel
  8.  * Networks and Distributed Computing
  9.  * Computing and Communications
  10.  * University of Washington
  11.  * Administration Builiding, AG-44
  12.  * Seattle, Washington, 98195, USA
  13.  * Internet: mikes@cac.washington.edu
  14.  *
  15.  * Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  16.  *
  17.  *
  18.  * Pine and Pico are registered trademarks of the University of Washington.
  19.  * No commercial use of these trademarks may be made without prior written
  20.  * permission of the University of Washington.
  21.  * 
  22.  * Pine, Pico, and Pilot software and its included text are Copyright
  23.  * 1989-1996 by the University of Washington.
  24.  * 
  25.  * The full text of our legal notices is contained in the file called
  26.  * CPYRIGHT, included with this distribution.
  27.  */
  28.  
  29. #ifndef    PICO_H
  30. #define    PICO_H
  31. /*
  32.  * Defined for attachment support
  33.  */
  34. #define    ATTACHMENTS    1
  35.  
  36.  
  37. /*
  38.  * defs of return codes from pine mailer composer.
  39.  */
  40. #define    BUF_CHANGED    0x01
  41. #define    COMP_CANCEL    0x02
  42. #define    COMP_EXIT    0x04
  43. #define    COMP_FAILED    0x08
  44. #define    COMP_SUSPEND    0x10
  45. #define    COMP_GOTHUP    0x20
  46.  
  47.  
  48. /*
  49.  * top line from the top of the screen for the editor to do 
  50.  * its stuff
  51.  */
  52. #define    COMPOSER_TOP_LINE    2
  53. #define    COMPOSER_TITLE_LINE    0
  54.  
  55.  
  56.  
  57. /*
  58.  * definitions of Mail header structures 
  59.  */
  60. struct hdr_line {
  61.         char text[256];
  62.         struct  hdr_line        *next;
  63.         struct  hdr_line        *prev;
  64. };
  65.  
  66.  
  67. /* 
  68.  *  This structure controls the header line items on the screen.  An
  69.  * instance of this should be created and passed in as an argument when
  70.  * pico is called. The list is terminated by an entry with the name
  71.  * element NULL.
  72.  */
  73.  
  74. struct headerentry {
  75.         char     *prompt;
  76.     char     *name;
  77. #if defined(DOS) || defined(HELPFILE)
  78.     short      help;
  79. #else
  80.     char    **help;
  81. #endif
  82.         int      prlen;
  83.         int      maxlen;
  84.         char    **realaddr;
  85.         int     (*builder)();        /* Function to verify/canonicalize val */
  86.     struct headerentry        *affected_entry, *next_affected;
  87.                      /* entry builder's 4th arg affects     */
  88.         char   *(*selector)();       /* Browser for possible values         */
  89.         char     *key_label;         /* Key label for key to call browser   */
  90.         unsigned  display_it:1;         /* field is to be displayed by default */
  91.         unsigned  break_on_comma:1;  /* Field breaks on commas              */
  92.         unsigned  is_attach:1;       /* Special case field for attachments  */
  93.         unsigned  rich_header:1;     /* Field is part of rich header        */
  94.         unsigned  only_file_chars:1; /* Field is a file name                */
  95.         unsigned  single_space:1;    /* Crush multiple spaces into one      */
  96.         unsigned  sticky:1;          /* Can't change this via affected_entry*/
  97.         unsigned  dirty:1;           /* We've changed this entry            */
  98.     unsigned  start_here:1;         /* begin composer on first on lit      */
  99. #ifdef    KS_OSDATAVAR
  100.     KS_OSDATAVAR             /* Port-Specific keymenu data */
  101. #endif
  102.     void     *bldr_private;      /* Data managed by builders            */
  103.         struct    hdr_line        *hd_text;
  104. };
  105.  
  106.  
  107. /*
  108.  * Structure to pass as arg to builders
  109.  */
  110. typedef struct bld_arg {
  111.     char           *tptr;    /* pointer to malloc'd text              */
  112.     void          **xtra;    /* builder keeps track of private info here  */
  113.     struct bld_arg *next;    /* next one in list if more than one affected*/
  114. } BUILDER_ARG;
  115.  
  116.  
  117. /*
  118.  * structure to keep track of header display
  119.  */
  120. struct on_display {
  121.     int             p_off;            /* offset into line */
  122.     int             p_len;            /* length of line   */
  123.     int             p_line;        /* physical line on screen */
  124.     int             top_e;            /* topline's header entry */
  125.     struct hdr_line    *top_l;            /* top line on display */
  126.     int             cur_e;            /* current header entry */
  127.     struct hdr_line    *cur_l;            /* current hd_line */
  128. };                        /* global on_display struct */
  129.  
  130.  
  131. /*
  132.  * Structure to handle attachments
  133.  */
  134. typedef struct pico_atmt {
  135.     char *description;            /* attachment description */
  136.     char *filename;            /* file/pseudonym for attachment */
  137.     char *size;                /* size of attachment */
  138.     char *id;                /* attachment id */
  139.     unsigned short flags;
  140.     struct pico_atmt *next;
  141. } PATMT;
  142.  
  143.  
  144. /*
  145.  * Flags for attachment handling
  146.  */
  147. #define    A_FLIT    0x0001            /* Accept literal file and size      */
  148. #define    A_ERR    0x0002            /* Problem with specified attachment */
  149. #define    A_TMP    0x0004            /* filename is temporary, delete it  */
  150.  
  151.  
  152. /*
  153.  * Master pine composer structure.  Right now there's not much checking
  154.  * that any of these are pointing to something, so pine must have them pointing
  155.  * somewhere.
  156.  */
  157. typedef struct pico_struct {
  158.     void  *msgtext;            /* ptrs to malloc'd arrays of char */
  159.     char  *pine_anchor;            /* ptr to pine anchor line */
  160.     char  *pine_version;        /* string containing Pine's version */
  161.     char  *alt_ed;            /* name of alternate editor or NULL */
  162.     char  *alt_spell;            /* Checker to use other than "spell" */
  163.     char  *oper_dir;            /* Operating dir (confine to tree) */
  164.     char  *quote_str;            /* prepended to lines of quoted text */
  165.     int    fillcolumn;            /* where to wrap */
  166.     int    menu_rows;            /* number of rows in menu (0 or 2) */
  167.     PATMT *attachments;            /* linked list of attachments */
  168.     long   pine_flags;            /* entry mode flags */
  169.     void  (*helper)();            /* Pine's help function  */
  170.     int   (*showmsg)();            /* Pine's display_message */
  171.     void  (*keybinit)();        /* Pine's keyboard initializer  */
  172.     int   (*raw_io)();            /* Pine's Raw() */
  173.     long  (*newmail)();            /* Pine's report_new_mail */
  174.     long  (*msgntext)();        /* callback to get msg n's text */
  175.     int   (*upload)();            /* callback to rcv uplaoded text */
  176.     char *(*ckptdir)();            /* callback for checkpoint file dir */
  177.     char *(*exittest)();        /* callback to verify exit request */
  178.     char *(*canceltest)();        /* callback to verify cancel request */
  179.     int   (*mimetype)();        /* callback to display mime type */
  180.     void  (*expander)();        /* callback to expand address lists */
  181.     void  (*resize)();            /* callback handling screen resize */
  182. #if defined(DOS) || defined(HELPFILE)
  183.     short search_help;
  184.     short ins_help;
  185.     short composer_help;
  186.     short browse_help;
  187. #else
  188.     char  **search_help;
  189.     char  **ins_help;
  190.     char  **composer_help;
  191.     char  **browse_help;
  192. #endif
  193.     struct headerentry *headents;
  194. } PICO;
  195.  
  196.  
  197. #ifdef    MOUSE
  198. /*
  199.  * Mouse buttons.
  200.  */
  201. #define M_BUTTON_LEFT        0
  202. #define M_BUTTON_MIDDLE        1
  203. #define M_BUTTON_RIGHT        2
  204.  
  205.  
  206. /*
  207.  * Flags.  (modifier keys)
  208.  */
  209. #define M_KEY_CONTROL        0x01    /* Control key was down. */
  210. #define M_KEY_SHIFT        0x02    /* Shift key was down. */
  211.  
  212.  
  213. /*
  214.  * Mouse Events
  215.  */
  216. #define M_EVENT_DOWN        0x01    /* Mouse went down. */
  217. #define M_EVENT_UP        0x02    /* Mouse went up. */
  218. #define M_EVENT_TRACK        0x04    /* Mouse tracking */
  219.  
  220. /*
  221.  * Mouse event information.
  222.  */
  223. typedef struct mouse_struct {
  224.     char    mevent;        /* Indicates type of event:  Down, Up or 
  225.                    Track */
  226.     char    down;        /* TRUE when mouse down event */
  227.     char    doubleclick;    /* TRUE when double click. */
  228.     int    button;        /* button pressed. */
  229.     int    flags;        /* What other keys pressed. */
  230.     int    row;
  231.     int    col;
  232. } MOUSEPRESS;
  233.  
  234.  
  235.  
  236. #ifdef    ANSI
  237. typedef    unsigned long (*mousehandler_t)(int, int, int, int, int);
  238. #else
  239. typedef    unsigned long (*mousehandler_t)();
  240. #endif
  241.  
  242. typedef struct point {
  243.     unsigned    r:8;        /* row value                */
  244.     unsigned    c:8;        /* column value                */
  245. } MPOINT;
  246.  
  247.  
  248. typedef struct menuitem {
  249.     unsigned         val;    /* return value                */
  250.     mousehandler_t    action;    /* action to perform            */
  251.     MPOINT         tl;    /* top-left corner of active area    */
  252.     MPOINT         br;    /* bottom-right corner of active area    */
  253.     MPOINT         lbl;    /* where the label starts        */
  254.     char        *label;
  255.     void            (*label_hiliter)();
  256.     struct menuitem *next;
  257. } MENUITEM;
  258. #endif
  259.  
  260.  
  261. /*
  262.  * Structure used to manage keyboard input that comes as escape
  263.  * sequences (arrow keys, function keys, etc.)
  264.  */
  265. typedef struct  KBSTREE {
  266.     char    value;
  267.         int     func;              /* Routine to handle it         */
  268.     struct    KBSTREE *down; 
  269.     struct    KBSTREE    *left;
  270. } KBESC_T;
  271.  
  272. /*
  273.  * Protos for functions used to manage keyboard escape sequences
  274.  * NOTE: these may ot actually get defined under some OS's (ie, DOS, WIN)
  275.  */
  276. extern    int    kbseq();
  277. extern    void    kpinsert();
  278. extern    void    kbdestroy();
  279.  
  280.  
  281. /*
  282.  * various flags that they may passed to PICO
  283.  */
  284. #define    P_DELRUBS    0x40000000    /* map ^H to forwdel           */
  285. #define    P_LOCALLF    0x20000000    /* use local vs. NVT EOL       */
  286. #define    P_BODY        0x10000000    /* start composer in body       */
  287. #define    P_HEADEND    0x08000000    /* start composer at end of header */
  288. #define    P_VIEW        MDVIEW        /* read-only               */
  289. #define    P_FKEYS        MDFKEY        /* run in function key mode        */
  290. #define    P_SECURE    MDSCUR        /* run in restricted (demo) mode   */
  291. #define    P_TREE        MDTREE        /* restrict to a subtree       */
  292. #define    P_SUSPEND    MDSSPD        /* allow ^Z suspension           */
  293. #define    P_ADVANCED    MDADVN        /* enable advanced features       */
  294. #define    P_CURDIR    MDCURDIR    /* use current dir for lookups       */
  295. #define    P_ALTNOW    MDALTNOW    /* enter alt ed sans hesitation       */
  296. #define    P_SUBSHELL    MDSPWN        /* spawn subshell for suspend       */
  297. #define    P_COMPLETE    MDCMPLT        /* enable file name completion     */
  298. #define    P_DOTKILL    MDDTKILL    /* kill from dot to eol           */
  299. #define    P_SHOCUR    MDSHOCUR    /* cursor follows hilite in browser*/
  300. #define    P_HIBITIGN    MDHBTIGN    /* ignore chars with hi bit set    */
  301. #define    P_DOTFILES    MDDOTSOK    /* browser displays dot files       */
  302. #define    P_ABOOK        MDHDRONLY    /* called as address book editor   */
  303. #define    P_ALLOW_GOTO    MDGOTO        /* support "Goto" in file browser  */
  304.  
  305. /*
  306.  * definitions for various PICO modes 
  307.  */
  308. #define    MDWRAP        0x00000001    /* word wrap            */
  309. #define    MDSPELL        0x00000002    /* spell error parcing        */
  310. #define    MDEXACT        0x00000004    /* Exact matching for searches    */
  311. #define    MDVIEW        0x00000008    /* read-only buffer        */
  312. #define MDOVER        0x00000010    /* overwrite mode        */
  313. #define MDFKEY        0x00000020    /* function key  mode        */
  314. #define MDSCUR        0x00000040    /* secure (for demo) mode    */
  315. #define MDSSPD        0x00000080    /* suspendable mode        */
  316. #define MDADVN        0x00000100    /* Pico's advanced mode        */
  317. #define MDTOOL        0x00000200    /* "tool" mode (quick exit)    */
  318. #define MDBRONLY    0x00000400    /* indicates standalone browser    */
  319. #define MDCURDIR    0x00000800    /* use current dir for lookups    */
  320. #define MDALTNOW    0x00001000    /* enter alt ed sans hesitation */
  321. #define    MDSPWN        0x00002000    /* spawn subshell for suspend    */
  322. #define    MDCMPLT        0x00004000    /* enable file name completion  */
  323. #define    MDDTKILL    0x00008000    /* kill from dot to eol        */
  324. #define    MDSHOCUR    0x00010000    /* cursor follows hilite in browser */
  325. #define    MDHBTIGN    0x00020000    /* ignore chars with hi bit set */
  326. #define    MDDOTSOK    0x00040000    /* browser displays dot files   */
  327. #define    MDEXTFB        0x00080000    /* stand alone File browser     */
  328. #define    MDTREE        0x00100000    /* confine to a subtree         */
  329. #define    MDMOUSE        0x00200000    /* allow mouse (part. in xterm) */
  330. #define    MDONECOL    0x00400000    /* single column browser        */
  331. #define    MDHDRONLY    0x00800000    /* header editing exclusively   */
  332. #define    MDGOTO        0x01000000    /* support "Goto" in file browser */
  333.  
  334. /*
  335.  * Main defs 
  336.  */
  337. #ifdef    maindef
  338. PICO    *Pmaster = NULL;        /* composer specific stuff */
  339. char    *version = "2.9";        /* PICO version number */
  340.  
  341. #else
  342. extern    PICO *Pmaster;            /* composer specific stuff */
  343. extern    char *version;            /* pico version! */
  344.  
  345. #endif    /* maindef */
  346.  
  347.  
  348. /*
  349.  * Flags for FileBrowser call
  350.  */
  351. #define FB_READ        0x0001        /* Looking for a file to read. */
  352. #define FB_SAVE        0x0002        /* Looking for a file to save. */
  353.  
  354.  
  355. /*
  356.  * number of keystrokes to delay removing an error message, or new mail
  357.  * notification, or checkpointing
  358.  */
  359. #define    MESSDELAY    25
  360. #define    NMMESSDELAY    60
  361. #ifndef CHKPTDELAY
  362. #define    CHKPTDELAY    200
  363. #endif
  364.  
  365.  
  366. /*
  367.  * defs for keypad and function keys...
  368.  */
  369. #define K_PAD_UP        0x0811
  370. #define K_PAD_DOWN        0x0812
  371. #define K_PAD_RIGHT        0x0813
  372. #define K_PAD_LEFT        0x0814
  373. #define K_PAD_PREVPAGE        0x0815
  374. #define K_PAD_NEXTPAGE        0x0816
  375. #define K_PAD_HOME        0x0817
  376. #define K_PAD_END        0x0818
  377. #define K_PAD_DELETE        0x0819
  378. #define BADESC            0x0820
  379. #define K_MOUSE            0x0821
  380. #define K_SCROLLUPLINE        0x0822
  381. #define K_SCROLLDOWNLINE    0x0823
  382. #define K_SCROLLTO        0x0824
  383. #define K_XTERM_MOUSE        0x0825
  384. #define K_DOUBLE_ESC        0x0826
  385. #define K_SWALLOW_TIL_Z        0x0827
  386. #define K_SWALLOW_UP        0x0828
  387. #define K_SWALLOW_DOWN        0x0829
  388. #define K_SWALLOW_RIGHT        0x0830
  389. #define K_SWALLOW_LEFT        0x0831
  390. #define K_KERMIT        0x0832
  391. #define NODATA            0x08FF
  392.  
  393. /*
  394.  * defines for function keys
  395.  */
  396. #define F1      0x1001                  /* Functin key one              */
  397. #define F2      0x1002                  /* Functin key two              */
  398. #define F3      0x1003                  /* Functin key three            */
  399. #define F4      0x1004                  /* Functin key four             */
  400. #define F5      0x1005                  /* Functin key five             */
  401. #define F6      0x1006                  /* Functin key six              */
  402. #define F7      0x1007                  /* Functin key seven            */
  403. #define F8      0x1008                  /* Functin key eight            */
  404. #define F9      0x1009                  /* Functin key nine             */
  405. #define F10     0x100A                  /* Functin key ten              */
  406. #define F11     0x100B                  /* Functin key eleven           */
  407. #define F12     0x100C                  /* Functin key twelve           */
  408.  
  409.  
  410. /*
  411.  * useful function definitions
  412.  */
  413. #ifdef    ANSI
  414. int   pico(PICO *);
  415. int   pico_file_browse(PICO *, char *, char *, char *, int);
  416. void *pico_get(void);
  417. void  pico_give(void *);
  418. int   pico_readc(void *, unsigned char *);
  419. int   pico_writec(void *, int);
  420. int   pico_puts(void *, char *);
  421. int   pico_seek(void *, long, int);
  422. int   pico_replace(void *, char *);
  423. int   pico_fncomplete(char *, char *, int);
  424. #if defined(DOS) || defined(OS2)
  425. int   pico_nfsetcolor(char *);
  426. int   pico_nbsetcolor(char *);
  427. int   pico_rfsetcolor(char *);
  428. int   pico_rbsetcolor(char *);
  429. #endif
  430. #ifdef    MOUSE
  431. int   init_mouse();
  432. void  end_mouse();
  433. int   mouseexist();
  434. int   register_mfunc(mousehandler_t, int, int, int, int);
  435. void  clear_mfunc(mousehandler_t);
  436. unsigned long mouse_in_content(int, int, int, int, int);
  437. unsigned long mouse_in_pico(int, int, int, int, int);
  438. void  mouse_get_last(mousehandler_t *, MOUSEPRESS *);
  439. int   checkmouse(unsigned *, int, int, int);
  440. void  invert_label(int, MENUITEM *);
  441. void  mouseon();
  442. void  mouseoff();
  443. #endif    /* MOUSE */
  444.  
  445. #else
  446. int   pico();
  447. int   pico_file_browse();
  448. void *pico_get();
  449. void  pico_give();
  450. int   pico_readc();
  451. int   pico_writec();
  452. int   pico_puts();
  453. int   pico_seek();
  454. int   pico_replace();
  455. int   pico_fncomplete();
  456. #ifdef    MOUSE
  457. int   init_mouse();
  458. void  end_mouse();
  459. int   mouseexist();
  460. int   register_mfunc();
  461. void  clear_mfunc();
  462. unsigned long mouse_in_content();
  463. void  mouse_get_last();
  464. int   checkmouse();
  465. void  invert_label();
  466. void  mouseon();
  467. void  mouseoff();
  468. #endif    /* MOUSE */
  469. #endif
  470.  
  471. #endif    /* PICO_H */
  472.